package com.wjw.service;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.List;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.wjw.entity.Category;
import com.wjw.dao.CategoryMapper;
/**
*@author WuJianWei
*@date 2022/2/28 20:00
*/
@Service
public class CategoryService extends ServiceImpl<CategoryMapper, Category> {
    public List<Category> getCategory(){
        List<Category> categories = baseMapper.selectList(null);
        return categories;
    }
    public Integer getProductByCategoryName(String categoryName){
        LambdaQueryWrapper<Category> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(Category::getCategoryName,categoryName);
        Category category = baseMapper.selectOne(wrapper);
        return category.getCategoryId();
    }
}
